#ifndef POLYGON_H
#define POLYGON_H

#include <vector>
#include "mesh.h"
#include "vertex.h"
#include "IObject.h"
#include "IDrawEvent.h"
#include "ICollidable.h"

class Polygon: IObject, IDrawEvent, ICollidable {
protected:
	Mesh * mesh;
	Vertex center;
	float angle; //fixed angle of rotation around center of mass
	float m; //center of mass
	float I; //moment of inertia
	float s[2][2]; //rotation mairix
public:
	Polygon(const char* file_name);
	
	void SetCenter(Vertex v);
	void SetAngle(float a);
	void SetM(float mass);
	void SetI(float f);
	virtual Vertex nthVertex(int n);
	float getAngle();
	virtual void CalcRotMatrix();

	virtual Vertex getCenter();
	virtual void collide(float j, Vertex n, Vertex p, Vertex cen);
	virtual void draw();
	virtual Vertex ClosestPoint(Vertex v);
	virtual bool InObject(Vertex v);
	virtual bool IsEdgeCollision(Vertex v);
	virtual Vertex GetNormal(Vertex v);
	virtual float GetM();
	virtual float GetI();

	virtual Vertex GetV();
	virtual float GetV_angle();
};


#endif